/**
 * Copyright (c) 2015-2018, Golly Hu 胡高 (3722711@qq.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.hg.jfsa.manage.controller.module.news.validator;

import com.jfinal.core.Controller;

import cn.hg.base.jfinal.validator.BaseValidator;

/**
 * @author Golly
 */
public class NewsValidator extends BaseValidator {

	/*
	 * (non-Javadoc)
	 * @see com.jfinal.validate.Validator#handleError(com.jfinal.core.Controller)
	 */
	@Override
	protected void handleError (Controller c) {}

	/*
	 * (non-Javadoc)
	 * @see com.jfinal.validate.Validator#validate(com.jfinal.core.Controller)
	 */
	@Override
	protected void validate (Controller c) {
		this.setShortCircuit(true);
		this.validateRequired("news.title", "titleMsg", "标题为必填！");
		this.validateString("news.title", 2, 100, "titleMsg", "标题必须填写2到100长度的字符！");
		this.validateRequired("news.status", "statusMsg", "状态为必填！");
		this.validateRequired("news.categoryId", "categoryMsg", "新闻分类为必填！");
		this.validateInteger("news.baseHits", 0, Short.MAX_VALUE, "baseHits", "初始点击数必须为0-" + Short.MAX_VALUE + "以内！");
	}

}
